import { IsNumber, IsOptional, IsString, MaxLength, MinLength } from 'class-validator';

import { ApiProperty } from '@nestjs/swagger';
import { PageOptionsDto } from 'src/common/dto/page.dto';

export class CreateTagDto {
  @ApiProperty({ description: '标签名称' })
  @IsString()
  @MinLength(2)
  @MaxLength(50)
  name: string;

  @ApiProperty({ description: '使用次数' })
  @IsNumber()
  @MinLength(1)
  useNumber: number;

  @ApiProperty({ description: '状态' })
  @IsNumber()
  @MinLength(1)
  status: number;

  @ApiProperty({ description: '分类ID' })
  @IsNumber()
  @MinLength(1)
  categoryId: number;

  @ApiProperty({ description: '文章' })
  @IsOptional()
  articles?: number[];
}
export class UpdateArticleTagDto extends CreateTagDto {
  @ApiProperty({
    description: '需要更新的ID',
    type: Number,
  })
  id: number;
}
export class ListTagDto extends PageOptionsDto {
  @ApiProperty({
    description: '标签名称',
  })
  @IsOptional()
  label?: string;

  @ApiProperty({
    description: '标签值',
  })
  @IsOptional()
  value?: string;

  @ApiProperty({ description: '文章' })
  @IsOptional()
  articles?: number[];
}

export class DeleteTagDto {
  @ApiProperty({
    description: '需要删除的标签',
    type: Number,
  })
  id: number;
}
